
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <link rel="stylesheet" href="__PUBLIC__/css/common.css">
   <link rel="stylesheet" href="__PUBLIC__/css/main.css">
   <script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
   <script type="text/javascript" src="__PUBLIC__/js/colResizable-1.3.min.js"></script>
   <script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
  
   <script type="text/javascript">
      $(function(){  
        $(".list_table").colResizable({
          liveDrag:true,
          gripInnerHtml:"<div class='grip'></div>", 
          draggingClass:"dragging", 
          minWidth:30
        }); 
        
      }); 
   </script>
   <title>查看培训中心</title>
   
   <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=uu7qMGBqMYQbFMTdNhy65ZgM"></script>
<!--引用百度地图API-->
<style type="text/css">
    html,body{margin:0;padding:0;}
    .iw_poi_title {color:#CC5522;font-size:14px;font-weight:bold;overflow:hidden;padding-right:13px;white-space:nowrap}
    .iw_poi_content {font:12px arial,sans-serif;overflow:visible;padding-top:4px;white-space:-moz-pre-wrap;word-wrap:break-word}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?key=&v=1.1&services=true"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=uu7qMGBqMYQbFMTdNhy65ZgM"></script>
   
 </head>
 <body>
 <!--
 登陆成功{{$_SESSION['user']['username']}}
 -->
     <div id="forms" class="mt10">
        <div class="box">
          <div class="box_border">
            <div class="box_center">
              <form action="{{:U('/Center/centerEdit')}}" id="form" class="jqtransform" method="post" enctype="multipart/form-data">
              <table>
              <tbody>
              <tr>
              <td>
               <table class="form_table pt15 pb15" width="100%" border="0" cellpadding="0" cellspacing="0">
               	<tr>
               		<td class="td_right">机构名称:</td>
               		<td class=""><input type="text" name="name" value="{{$list.name}}" class="input-text lh30" size="40">
               		<input type="hidden" name="u_id" value="{{$list.u_id}}" class="input-text lh30" size="40">
               		<input type="hidden" name="id" value="{{$list.id}}" class="input-text lh30" size="40"></td>
               	</tr>
               	<tr>
               		<td class="td_right">机构图片:</td>
               		<td>
               		<foreach name="centerImage" item="im">
               		<div style="position:relative;float:left;margin-right:5px;"><!-- javascript:$(this).parent().remove(); --> 
               		<div style="cursor:pointer;font-size:18px;font-weight:bold;text-align:center;width:18px;height:18px;background:#ccc;color:red;position:absolute;right:0px;top:0px;" onclick="del();$(this).parent().remove();delImg({{$im.id}});">×</div>
							<img alt="__PUBLIC__/Uploads/image/{{$im.image}}" src="__PUBLIC__/Uploads/image/{{$im.image}}" style="width: 100px;">
							</div>
					</foreach>
               		<a href="javascript:();" class="btn btn-success" onclick="addPic()">添加图片</a></td>
               	</tr>
               	<tr>
					<td class="td_right"></td>
					<td><div id="picDiv" class="span12"></div></td>
               	</tr>
               	<tr>
               		<td class="td_right">负责人:</td>
               		<td class=""><input type="text" name="person" value="{{$list.person}}" class="input-text lh30" size="40"></td>
               	</tr>
               	<tr>
               		<td class="td_right">联系电话:</td>
               		<td class=""><input type="text" name="phone" value="{{$list.phone}}" class="input-text lh30" size="40"></td>
               	</tr>
               	<tr>
               		<td class="td_right">地址:</td>
               		<td class=""><input type="text" name="address" value="{{$list.address}}" oninput="OnInput (event)" onpropertychange="OnPropChanged (event)" class="input-text lh30" size="40"></td>
               	</tr>
               	<tr>
               		<td class="td_right"></td>
               		<td class="" style="font-size: 12px;color: #777;">请点击地图上标记点处获取更精确的经纬度<br>便于判断用户与您的距离</td>
               	</tr>
               	<tr>
               		<td class="td_right">经度:</td>
               		<td class=""><input type="text" name="long" value="{{$list.long}}" id="longitude" class="input-text lh30" size="40"></td>
               	</tr>
               	<tr>
               		<td class="td_right">纬度:</td>
               		<td class=""><input type="text" name="lat" value="{{$list.lat}}" id="latitude" class="input-text lh30" size="40"></td>
               	</tr>
               	<tr>
               		<td class="td_right">是否认证:</td>
               		<td class="">
               		<if condition="($list.authentication eq '已认证')">
	            		<input type="radio" name="authentication" value="已认证" checked="checked"> 已认证
                    	<input type="radio" name="authentication" value="未认证" > 未认证
            		<else/>
	            		<input type="radio" name="authentication" value="已认证"> 已认证
                    	<input type="radio" name="authentication" value="未认证" checked="checked" > 未认证
            		</if>
               		</td>
               	</tr>
               	<tr>
               		<td class="td_right">校长:</td>
               		<td class=""><input type="text" name="principal" value="{{$list.principal}}" class="input-text lh30" size="40"></td>
               	</tr>
               	<tr>
               		<td class="td_right">经营内容:</td>
               		<td class=""><textarea name="editor" class="input-text lh30" style="height: 120px;width: 300px;">{{$list.editor}}</textarea></td>
               	</tr>
               	<tr>
               		<td class="td_right">用户名:</td>
               		<td class=""><input type="text" name="username" disabled="disabled" value="{{$list.username}}" class="input-text lh30" size="40"></td>
               	</tr>
               	<tr>
               		<td class="td_right">密码:</td>
               		<td class=""><input type="text" name="password" value="{{$list.password}}" class="input-text lh30" size="40"></td>
               	</tr>
               	<tr>
               		<td class="td_right"></td>
               		<td class=""><div id="test" style="color: red;"></div></td>
               	</tr>
                 <tr>
                   <td class="td_right">&nbsp;</td>
                   <td class="">
                     <input type="button" class="btn btn82 btn_save2" onclick="onSub1();" value="保存">
                     <!-- <input type="submit" name="button" class="btn btn82 btn_save2" value="保存">  -->
                    <input type="reset" name="button" class="btn btn82 btn_res" value="重置"> 
                   </td>
                 </tr>
               </table>
               </td>
               <td width="5%"></td>
               <td class="map" style="vertical-align:top;" width="50%">
					 <!--百度地图容器-->
					<div style="width:100%;height:550px;border:#ccc solid 1px;" id="dituContent"></div>
					<div style="margin-top: 20px;">请输入关键字：<input id="address" size="30" type="text" oninput="OnInput (event)" onpropertychange="OnPropChanged (event)" style="border: 1px solid #ddd;"></div>
               </td>
               </tr>
               </tbody>
               </table>
               </form>
            </div>
          </div>
        </div>
     </div>
  	 <script type="text/javascript">
	    function addPic(){
			$('#picDiv').append('<div class="clearfix" style="position:relative;height:32px;"><input style="width:280px;position:static;" onchange="checkPic(this)" type="file" name="img[]"/><a href="javascript:();" onclick="javascript:$(this).parent().remove();">移除</a><span class="required picError"></span></div>');
		}
	    function delImg(id){
	    	$.post("{{:U('Center/delImg')}}",{ id : id},function(data){
	    	})
	    }
        function del()
        {
            if (confirm("确定要删除吗？" ))
            {
                return true ;
            }
            else
            {
                return false ;
            }
        }
		//提交前执行
		function onSub1(){
			var name = $("input[name='name']").val();
			var img = $("input[name='img[]']").val();
			var person = $("input[name='person']").val();
			var phone = $("input[name='phone']").val();
			var address = $("input[name='address']").val();
			var username = $("input[name='username']").val();
			var password = $("input[name='password']").val();
			//判断用户名不能为空
			if(name == ""){
				$("#test").html("课程名称不能为空!");
				return false;
			}else{
				$("#test").html("");
			}
			var image = 0;
			$("*[name='img[]']").each(function(index,item){
				var img_reg = /^$|^(([a-zA-Z0-9_]+):(\\.+))|([a-zA-Z0-9_]+)(.JPEG|.jpeg|.JPG|.jpg|.GIF|.gif|.BMP|.bmp|.PNG|.png)$/;
				var imgs = $(this).val().trim();
				if(!img_reg.test(imgs)){
					image = 1;
				}else{
					$("#test").html("");
				}
		    });
			if(image == 1){
				$("#test").html("图片格式错误!");
				return false;
			}else{
				$("#test").html("");
			}
			//判断负责人不能为空
			if(person == ""){
				$("#test").html("负责人不能为空!");
				return false;
			}else{
				$("#test").html("");
			}
			//判断联系电话不能为空
			var phone_reg = /^[0-9]*[1-9][0-9]*$/;
			if(phone == "" || !phone_reg.test(phone)){
				$("#test").html("联系电话不能为空或格式错误!");
				return false;
			}else{
				$("#test").html("");
			}
			//判断密码不能为空
			if(password == ""){
				$("#test").html("密码不能为空!");
				return false;
			}else{
				$("#test").html("");
			}
			$("#form").submit();
		}
		/*function onUsername(){
			var username = $("input[name='username']").val();
			//var usernames = "";
			var u_id = $("input[name='u_id']").val();
			$.post("{{:U('Center/username_id')}}",{u_id:u_id,username:username},function(data){
				usernames = data;
			});
			return usernames;
		}
		//输入时判断用户名已存在
		function onUserame(){
			var username = $("input[name='username']").val();
			var u_id = $("input[name='u_id']").val();
			$.post("{{:U('Center/username_id')}}",{u_id:u_id,username:username},function(data){
				if(data == "success"){
					$("#test").html("");
				}else{
					$("#test").html("用户名已存在!");
				}
			});
		}*/


		//地图
createMap();
    //创建和初始化地图函数：
    function initMap(){
    	var lng = $("input[name='long']").val();
    	var lat = $("input[name='lat']").val();
    	if ($.trim(lng) == ""
    	    || $.trim(lat) == "") {
        	//if (window.navigator.geolocation) {
        	//	window.navigator.geolocation.getCurrentPosition(createMap);
        	//} else {
        	//	alert("浏览器不支持html5来获取地理位置信息");
        	//}
    	//} else {
    		createMap();//创建地图
    	}

        //createMap();//创建地图
        //setMapEvent();//设置地图事件
        //addMapControl();//向地图添加控件
    }

    // Firefox, Google Chrome, Opera, Safari, Internet Explorer from version 9
    var address = "";
   function OnInput (event) {
       address = event.target.value;
       createMap();
   }
// Internet Explorer
   function OnPropChanged (event) {
       if (event.propertyName.toLowerCase () == "value") {
           address = event.target.value;
       }
   }
    
    //创建地图函数：
    function createMap(position){
    	// 获取到当前位置经纬度  本例中是chrome浏览器取到的是google地图中的经纬度
    	var lng = $("input[name='long']").val();//118.778074;
    	var lat = $("input[name='lat']").val();//32.057236;
    	if ($.trim(lng) == ""
    	    || $.trim(lat) == "") {
        	if (position != null) {
        		lng = position.coords.longitude;
        		lat = position.coords.latitude;
        	} else {
        		lng = 118.46;
        		lat = 32.03;
        	}
    	}

    	// 调用百度地图api显示
        var map = new BMap.Map("dituContent");//在百度地图容器中创建一个地图
        var point = new BMap.Point(lng, lat);//118.778074,32.057236);//定义一个中心点坐标
        map.centerAndZoom(point,12);//设定地图的中心点和坐标并将地图显示在地图容器中

        
    	// 创建地址解析器实例
    	var myGeo = new BMap.Geocoder();
    	// 将地址解析结果显示在地图上,并调整地图视野
    	myGeo.getPoint(address, function(point){
    		if (point) {
    			map.centerAndZoom(point, 16);
    			map.addOverlay(new BMap.Marker(point));
    	    	marker.enableDragging();           // 可拖拽
                var p = marker.getPosition();  //获取marker的位置
        		//alert("当前坐标是" + p.lng + "," + p.lat); 
        		document.getElementById("longitude").value=p.lng;
        		document.getElementById("latitude").value=p.lat; 
    		}
    	}, "");


        
    	var marker = new BMap.Marker(point);// 创建标注
    	map.addOverlay(marker);             // 将标注添加到地图中
    	marker.enableDragging();           // 可拖拽

        //点击地图添加设置点并获取坐标
    	map.addEventListener("click", function (e) {
    	    map.removeOverlay(marker); //如果marker已经存在，删除标记
            checkMaker();
            point = new BMap.Point(e.point.lng, e.point.lat);//捕捉点击的坐标值
            marker = new BMap.Marker(point); //给标记赋新坐标值
            map.addOverlay(marker); //添加新标记
            var p = marker.getPosition();  //获取marker的位置
    		//alert("当前坐标是" + p.lng + "," + p.lat); 
    		document.getElementById("longitude").value=p.lng;
    		document.getElementById("latitude").value=p.lat; 
            //点击地图反馈地址信息-存在问题
    		var pt = e.point;
    		myGeo.getLocation(pt, function(rs){
    			var addComp = rs.addressComponents;
    			alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);
    		});   
    		
            });
        function checkMaker() {
          if (marker != null) 
          map.removeOverlay(marker); //如果marker已经存在，删除标记
        };
        
        window.map = map;//将map变量存储在全局
        setMapEvent();//设置地图事件
        addMapControl();//向地图添加控件
    }
    
    //地图事件设置函数：
    function setMapEvent(){
        map.enableDragging();//启用地图拖拽事件，默认启用(可不写)
        map.enableScrollWheelZoom();//启用地图滚轮放大缩小
        map.enableDoubleClickZoom();//启用鼠标双击放大，默认启用(可不写)
        map.enableKeyboard();//启用键盘上下左右键移动地图
    }
    
    //地图控件添加函数：
    function addMapControl(){
        //向地图中添加缩放控件
	var ctrl_nav = new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_LARGE});
	map.addControl(ctrl_nav);
        //向地图中添加缩略图控件
	var ctrl_ove = new BMap.OverviewMapControl({anchor:BMAP_ANCHOR_BOTTOM_RIGHT,isOpen:1});
	map.addControl(ctrl_ove);
        //向地图中添加比例尺控件
	var ctrl_sca = new BMap.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT});
	map.addControl(ctrl_sca);
    }
    
    initMap();//创建和初始化地图
	 </script>
	 
 </body>
  